home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / ACC / DRIVERS.ACC / CUSTOM.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  7.3 KB  |  336 lines

  1. /* ===================================================================
  2.  * FILE: CUSTOM.C
  3.  * ===================================================================
  4.  * DATE: November 24, 1992
  5.  *     January  15, 1993 Write the assign.sys out immediately for
  6.  *               a delete device.
  7.  * 
  8.  * DESCRIPTION: DRIVERS ACC
  9.  *
  10.  * This file handles the initializing and button management
  11.  * for the custom driver handling dialog box.
  12.  *
  13.  * COMPILER: TURBO C Version 2.0
  14.  */
  15.  
  16.  
  17. /* INCLUDE FILES
  18.  * ===================================================================
  19.  */
  20. #include <sys\gemskel.h>
  21. #include <tos.h>
  22. #include <linea.h>
  23.  
  24. #include "country.h"
  25. #include "drvhead.h"
  26. #include "drivers.h"
  27. #include "fixrsh.h"
  28. #include "mainstuf.h"
  29. #include "xform_do.h"
  30. #include "windows.h"
  31. #include "text.h"
  32. #include "fsmio.h"
  33. #include "mover.h"
  34. #include "options.h"
  35. #include "device.h"
  36. #include "modify.h"
  37.  
  38.  
  39. /* STRUCTURES
  40.  * ===================================================================
  41.  */
  42. struct foobar {
  43.     WORD    dummy;
  44.     WORD    *image;
  45.     };
  46.  
  47.  
  48.  
  49. /* EXTERN
  50.  * ===================================================================
  51.  */
  52. extern int AES_Version;
  53.  
  54.  
  55.  
  56. /* PROTOTYPES
  57.  * ===================================================================
  58.  */
  59. void    DoCustom( void );
  60. int    handle_custom( int button, WORD *msg );
  61. void    DoDeleteDevice( void );
  62. void    InitNames( void );
  63. DEV_PTR FindSelectedDevice( void );
  64.  
  65.  
  66.  
  67.  
  68. /* DEFINES
  69.  * ===================================================================
  70.  */
  71.  
  72.  
  73.  
  74. /* GLOBALS
  75.  * ===================================================================
  76.  */
  77.  
  78.  
  79. /* FUNCTIONS
  80.  * ===================================================================
  81.  */
  82.  
  83.  
  84. /* DoCustom()
  85.  * ===================================================================
  86.  */
  87. void
  88. DoCustom( void )
  89. {
  90.    PrevTree = ad_front;
  91.    Reset_Tree( ad_device );
  92.  
  93.    Disable( DMODIFY );
  94.    Disable( DDELETE );
  95.    NoExit( DMODIFY );
  96.    NoExit( DDELETE );
  97.  
  98.    device_mover_setup( device_head, device_count,
  99.           DBASE, DSLIDE, DUP, DDOWN,
  100.           DLINE0, DLINE11, DLINE, 0, 12 );
  101.     
  102.    Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. /* handle_custom()
  110.  * ===================================================================
  111.  */
  112. int
  113. handle_custom( int button, WORD *msg )
  114. {
  115.    int  quit;
  116.    DEV_PTR curptr;
  117.    
  118.    quit   = FALSE;
  119.       
  120.    /* Handle Double-clicking of the objects */   
  121.    if( ( button != -1 ) && ( button & 0x8000 ) )
  122.    {
  123.       button &= 0x7FFF;      
  124.    }   
  125.    
  126.    switch( button )
  127.    {
  128.      case DMENU:    Deselect( DMENU );
  129.             Reset_Tree( ad_front );     
  130.             InitNames();
  131.                     mover_setup( hdriver_head, cdriver_count,
  132.                          FBASE, FSLIDER, FUP, FDOWN,
  133.                    LINE0, LINE7, LINEBASE, 0, 8 );
  134.             Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  135.                  break;
  136.  
  137.      case DCOVER0:
  138.      case DCOVER1:
  139.      case DCOVER2:
  140.      case DCOVER3:
  141.      case DCOVER4:
  142.      case DCOVER5:
  143.      case DCOVER6:
  144.      case DCOVER7:
  145.      case DCOVER8:
  146.      case DCOVER9:
  147.      case DCOVER10:
  148.      case DCOVER11:
  149.           
  150.      case DUP:
  151.      case DDOWN:
  152.      case DBASE:
  153.      case DSLIDE:   device_mover_button( button );
  154.                  break;
  155.                   
  156.      case DDELETE:  DoDeleteDevice();
  157.             break;
  158.  
  159.      case DMODIFY:  Deselect( button );
  160.             curptr = FindSelectedDevice();
  161.             DoModify( DMODIFY, curptr );
  162.             break;
  163.            
  164.      case DADD:        Deselect( button );
  165.             DoModify( DADD, ( DEV_PTR )NULL );
  166.             break;
  167.  
  168.      default:     if( button == -1 )
  169.               {
  170.                 switch( msg[0] )
  171.                 {
  172.                   case WM_REDRAW: 
  173.                                break;
  174.                                    
  175.                   case AC_CLOSE:  quit = TRUE;
  176.                                break;
  177.                                        
  178.                   case WM_CLOSED: quit = TRUE;
  179.                                CloseWindow();
  180.                      break;
  181.  
  182.              case CT_KEY:
  183.                           break;
  184.                   default:
  185.                           break;
  186.                 }
  187.               }
  188.               break;
  189.    }
  190.    return( quit );
  191.  
  192. }
  193.  
  194.  
  195.  
  196.  
  197. /* DoDeleteDevice()
  198.  * =======================================================================
  199.  * Delete the Active Device Selected
  200.  */
  201. void
  202. DoDeleteDevice( void )
  203. {
  204.     DEV_PTR curptr;
  205.     
  206.     curptr = FindSelectedDevice();
  207.  
  208.     if( !curptr )
  209.        return;
  210.  
  211.     if( form_alert( 1, alert1 ) == 2 )
  212.     {
  213.        XDeselect( tree, DDELETE );
  214.        return;
  215.     }       
  216.  
  217.     if( DDEV( curptr ) == 21 )
  218.       cur_cdriver = -1;
  219.  
  220.     DeleteDevice( DDEV( curptr ) );
  221.  
  222.     /* Re-display mover_setup */
  223.     SetChangeFlag();
  224.     device_mover_setup( device_head, device_count,
  225.           DBASE, DSLIDE, DUP, DDOWN,
  226.           DLINE0, DLINE11, DLINE, 0, 12 );
  227.     Objc_draw( tree, DLINE, MAX_DEPTH, NULL );
  228.     XDeselect( tree, DBASE );
  229.  
  230.     Deselect( DDELETE );
  231.     Undo_Dnodes( device_head, TRUE );
  232.     
  233.     /* WRITE THE ASSIGN.SYS IMMEDIATELY */
  234.     write_assign();
  235. }
  236.  
  237.  
  238. /* InitNames()
  239.  * =======================================================================
  240.  * Initializes the Driver Names in the Chooser Tree.
  241.  * The 'tree' must already be set by the calling routine.
  242.  * If we can't find the device or the driver, then 
  243.  * set it to None Selected.
  244.  */
  245. void
  246. InitNames( void )
  247. {
  248.      DEV_PTR temp_device;
  249.      HDEVICE_PTR hptr;
  250.      int     num;
  251.  
  252.      hptr = NULL;
  253.      num  =  -1;
  254.      temp_device = find_device( 21 );    /* find the printer device */
  255.      if( temp_device )
  256.      {
  257.     num = FindCDriverIndex( DNAME( temp_device ) );
  258.         if( num != -1 )
  259.         {
  260.           hptr = Find_HDevice( num );  /* SET it visually inversed */
  261.         }
  262.      }
  263.  
  264.      ClearHFLAG( hdriver_head );
  265.      if( !temp_device || !hptr )
  266.      {     
  267.          cur_cdriver = -1;
  268.          
  269.          /* If there IS a driver, just not a FSM_GDOS one, display
  270.           * it anyway. IE: SLM804.SYS, a GDOS driver or META.SYS
  271.           */
  272.          if( temp_device )
  273.          {
  274.            strcpy( driver_text, drivers[ DNAME( temp_device ) ] ); /* Set Name to Show*/
  275.        strcat( driver_text, NonSpeedo );
  276.            TedText( FPRINTER ) = &driver_text[0];
  277.            
  278.            /* Allow Remove, but not CONFIG */
  279.        Enable( FREMOVE );
  280.        MakeExit( FREMOVE );
  281.        Disable( FCONFIG );
  282.        NoExit( FCONFIG );         
  283.          }
  284.      else
  285.      {
  286.        /* OTHERWISE, NULL IT and HIDE EVERYTHING...*/
  287.            TedText( FPRINTER ) = &driver_null[0];
  288.        Disable( FREMOVE );
  289.        Disable( FCONFIG );
  290.        NoExit( FREMOVE );
  291.        NoExit( FCONFIG );         
  292.      }  
  293.      return;
  294.      }
  295.  
  296.      if( temp_device )
  297.      {
  298.       if( hptr )
  299.       {
  300.              HFLAG( hptr ) = TRUE;
  301.              cur_cdriver = num;  
  302.              strcpy( driver_text, cdrivers[ num ] ); /* Set Name to Show*/
  303.              TedText( FPRINTER ) = &driver_text[0];
  304.  
  305.          Enable( FREMOVE );
  306.          Enable( FCONFIG );
  307.          MakeExit( FREMOVE );
  308.          MakeExit( FCONFIG );
  309.           }   
  310.      }            
  311. }
  312.  
  313.  
  314.  
  315. /* FindSelectedDevice()
  316.  * =======================================================================
  317.  */
  318. DEV_PTR
  319. FindSelectedDevice( void )
  320. {
  321.     int i;
  322.     DEV_PTR xdevice;
  323.  
  324.     xdevice = NULL;
  325.  
  326.     for( i = DCOVER0; i <= DCOVER11; i+= 6 )
  327.     {
  328.        if( IsSelected( i ) )
  329.        {
  330.       xdevice = Device_Slit[ (( i - 5 ) - DLINE0 ) / 6 ];
  331.       break;
  332.        }
  333.     }
  334.     return( xdevice );
  335. }
  336.